package com.xiangxiangjd.analyse;

import com.xiangxiangjd.analyse.config.token.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;

@MapperScan({"com.xiangxiangjd.analyse.mapper"})
//扫描公共模块下的包     注入注解
@ComponentScan(basePackages = {"com.xiangxiangjd.analyse"})
//@ServletComponentScan(value = "com.xiangxiangjd.analyse.config")
@ComponentScan(basePackages = {"com.xiangxiangjd.analyse.config"})
@SpringBootApplication
//启动缓存数据库
@EnableCaching
@EnableScheduling  //定时任务
@EnableAsync
@Slf4j
public class AnalyseApplication {





    public static void main(String[] args) {

        log.info("Springboot启动中...." );
        ConfigurableApplicationContext context = SpringApplication.run(AnalyseApplication.class, args);
        log.info("启动成功！");

        Environment environment = context.getBean(Environment.class);

        try {
            Runtime.getRuntime().exec("cmd /c start http://localhost:" + environment.getProperty("server.port"));

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    //     注入值
    @Bean
    public JwtUtils jwtUtils() {
        return new JwtUtils();
    }

}
